package yuejian_07.yuejian_07.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import yuejian_07.yuejian_07.R;

import yuejian_07.yuejian_07.javabean.Notice;

/**
 * Created by dell on 2017/10/30.
 */

public class NoticeListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context mContext;
    private List mDataList;
    private LayoutInflater mLayoutInflater1;

    public NoticeListAdapter(Context mContext, List mDataList) {
        this.mContext = mContext;
        this.mDataList = mDataList;
        mLayoutInflater1 = LayoutInflater.from(mContext);
    }

    @Override
    public int getItemCount() {
        return mDataList.size();
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final Notice entity = (Notice) mDataList.get(position);
        if (null == entity)
            return;
        //绑定数据
        NoticeListAdapter.ViewHolder viewHolder = (NoticeListAdapter.ViewHolder) holder;
        viewHolder.n_title.setText(entity.getN_title());
        // System.out.printf("activity_name");
        viewHolder.n_content.setText(entity.getN_content());
        viewHolder.n_date.setText(entity.getN_date());





    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        //创建ViewHolder
        View v = mLayoutInflater1.from(parent.getContext()).inflate(R.layout.cardview_notice, parent, false);
        return new NoticeListAdapter.ViewHolder(v);

    }

    //自定义的V
    public class ViewHolder extends RecyclerView.ViewHolder{

        TextView n_title,n_date,n_content;

        public ViewHolder(View itemView) {
            super(itemView);
            n_title = (TextView) itemView.findViewById(R.id.Notice_title);
            n_content= (TextView) itemView.findViewById(R.id.Notice_content);
            n_date= (TextView) itemView.findViewById(R.id.Notice_date);
        }
    }
}
